import { mapState, mapMutations, mapActions } from "vuex";
import { wxappAuth, getUser } from "@/api/user";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import { login, authorize } from "@/utils";

export function getUserInfo(data) {
	if (data.detail.errMsg == "getUserInfo:fail auth deny") {
		uni.showToast({
			title: "取消授权",
			icon: "none",
			duration: 2000,
		});
		return;
	}
	uni.showLoading({
		title: "登录中",
	});
	login()
		.then((res) => {
			this.$yrouter.reLaunch({
				path: cookie.get("redirect").replace(/\ /g, '')
			});
		})
		.catch((error) => {
			console.log(error);
			uni.showToast({
				title: error,
				icon: "none",
				duration: 2000,
			});
		});
}
